package com.agile.leetcode.recursive;

import java.util.Objects;

public class ReserveStr {
    public static void main(String[] args) {
        String abcde = reserve("abcde");
        System.out.println(abcde);
    }

    public static String reserve(String str) {
        if (Objects.equals(str, "") || str.length() == 0) return str;
        if (str.length() == 1) {
            return str;
        }
        return reserve(str.substring(1)) + str.substring(0, 1);
    }
}
